<?php




require_once '../source/core/run.php';
require_once 'admin.inc.php';
$action		= Core_Fun::rec_post("action");
$page		= Core_Fun::detect_number(Core_Fun::rec_post("page"),1);
if($page<1){$page=1;}
$comeurl	= "page=$page";

if(Core_Fun::rec_post('act')=='update'){
    updateajax(Core_Fun::rec_post('id'),Core_Fun::rec_post('action'));
}
switch($action){
    case 'add';
	    add();
		break;
	case 'saveadd';
	    saveadd();
		break;
	case 'edit';
	    edit();
		break;
	case 'saveedit';
	    saveedit();
		break;
	case 'del';
	    del();
		break;
	case 'setting';
	    setting();
		break;
	case 'add_nodelist';
	    add_nodelist();
		break;
	case 'saveadd_nodelist';
	    saveadd_nodelist();
		break;

	case 'edit_nodelist';
	    edit_nodelist();
		break;
	case 'saveadd_nodelist';
	    saveadd_nodelist();
		break;
	case 'saveedit_nodelist';
	    saveedit_nodelist();
		break;
	case 'add_nodeabout';
	    add_nodeabout();
		break;
	case 'saveadd_nodeabout';
	   	saveadd_nodeabout();
		break;
	case 'edit_nodeabout';
	    edit_nodeabout();
		break;
	case 'saveadd_nodeabout';
	   	saveadd_nodelist();
		break;
	case 'saveedit_nodeabout';
	   	saveedit_nodeabout();
		break;
	case 'edit_list';
	   	edit_list();
		break;
	case 'add_list';
	   	add_list();
		break;
	case 'saveadd_list';
	   	saveadd_list();
		break;
	case 'add_list';
	   	add_list();
		break;
	case 'saveedit_list';
	   	saveedit_list();
		break;
	case 'add_nodeoutside';
	   	add_nodeoutside();
		break;
	case 'edit_nodeoutside';
	   	edit_nodeoutside();
		break;
	case 'saveadd_nodeoutside';
	   	saveadd_nodeoutside();
		break;
	case 'saveedit_nodeoutside';
	   	saveedit_nodeoutside();
		break;
	default;
	    volist();
		break;
}

function volist(){
	Core_Auth::checkauth("categoryvolist");
	global $db,$tpl,$page;
    $pagesize	= 60;
	$searchsql	= " WHERE 1=1";
	$countsql	= "SELECT COUNT(catid) FROM ".DB_PREFIX."category".$searchsql;
    $total		= $db->fetch_count($countsql);
    $pagecount	= ceil($total/$pagesize);
	$nextpage	= $page+1;
	$prepage	= $page-1;
	$start		= ($page-1)*$pagesize;
	$sql		= "SELECT * FROM ".DB_PREFIX."category".
		          $searchsql." ORDER BY orders ASC LIMIT $start, $pagesize";
	$category		= $db->getall($sql);

	foreach($category as $key=>$value){
		$treeid     = getTreeID($value['rootid']);
        $moddata    = getCatModule($treeid);
		$category[$key]['modname'] = $moddata['modname'];
	}
    foreach($category as $key => $value){
    		if($value['depth']==0){
    			$category[$key]['tree_node'] = $value['catname'];
    		}else{
    			$tree = "";
    			if($value['depth']==1){
    				$tree = "&nbsp;&nbsp;├ ";
    			}else{
    				for($ii=2;$ii<=$value['depth'];$ii++){
    					$tree .= "&nbsp;&nbsp;│";
    				}
    				$tree .= "&nbsp;&nbsp;├ ";
    			}
    			$category[$key]['tree_node'] = $tree.$value['catname'];
    		}
    	}
	$url		= $_SERVER['PHP_SELF'];
	$showpage	= Core_Page::adminpage($total,$pagesize,$page,$url,10);
//	$tpl->assign("modname",$moddata['modname']);
	$tpl->assign("total",$total);
	$tpl->assign("pagecount",$pagecount);
	$tpl->assign("page",$page);
	$tpl->assign("showpage",$showpage);
	$tpl->assign("category",$category);
}


 function add_list() {
	//Core_Auth::checkauth("category_add");
	global $db,$tpl;
    $id = Core_Fun::rec_post('rootid');
	if(!Core_Fun::isnumber($id)){
		Core_Fun::halt("ID丢失","",2);
	}
    $treeid = getTreeID($id);
	$moddata = getCatModule($treeid);
    $orders = getOrders($rootid);
    $category['modname'] =$data['modname'];
	 $tpl->assign("rootid",$id);
	 $tpl->assign("modname",$moddata['modname']);
     $tpl->assign("root_select",selectCategoryOneNode($treeid, $rootid, 'rootid', '==请选择=='));
     $tpl->assign("orders",$orders);
    }



 function add_nodeoutside() {
	//Core_Auth::checkauth("category_add");
	global $tpl;
     $tpl->assign("orders",$orders);
    }


 function edit_nodeoutside() {
	//Core_Auth::checkauth("categorylistedit");
	global $db,$tpl;
    $id = Core_Fun::rec_post('id');
	if(!Core_Fun::isnumber($id)){
		Core_Fun::halt("ID丢失","",2);
	}
	$sql	= "SELECT * FROM ".DB_PREFIX."category WHERE catid=$id";
	$category	= $db->fetch_first($sql);
	if(!$category){
		Core_Fun::halt("数据不存在","",2);
	}else{
		$data = getData($id);
		$category['modname'] =$data['modname'];
	//	$tpl->assign("flag_checkbox",Core_Mod::checkbox($cate['flag'],"flag","审核"));
	//	$tpl->assign("elite_checkbox",Core_Mod::checkbox($cate['elite'],"elite","推荐"));
		$tpl->assign("id",$id);
		//$tpl->assign("root_select",selectCategoryOneNode($data['treeid'], $data['rootid'], 'rootid', '==请选择=='));
	    $tpl->assign("category",$category);
	}

    }







 function edit_list() {
	//Core_Auth::checkauth("categorylistedit");
	global $db,$tpl;
    $id = Core_Fun::rec_post('id');
	if(!Core_Fun::isnumber($id)){
		Core_Fun::halt("ID丢失","",2);
	}
	$sql	= "SELECT * FROM ".DB_PREFIX."category WHERE catid=$id";
	$category	= $db->fetch_first($sql);
	if(!$category){
		Core_Fun::halt("数据不存在","",2);
	}else{
		$data = getData($id);
		$category['modname'] =$data['modname'];
	//	$tpl->assign("flag_checkbox",Core_Mod::checkbox($cate['flag'],"flag","审核"));
	//	$tpl->assign("elite_checkbox",Core_Mod::checkbox($cate['elite'],"elite","推荐"));
		$tpl->assign("id",$id);
		$tpl->assign("root_select",selectCategoryOneNode($data['treeid'], $data['rootid'], 'rootid', '==请选择=='));
	    $tpl->assign("category",$category);
	}

    }













function saveadd_nodeoutside(){
	global $db;
	$catname			= Core_Fun::rec_post('catname',1);
    $modalias			= Core_Fun::rec_post('modalias',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);
	$founderr			= false;

	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}

	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$catid	= $db->fetch_newid("SELECT MAX(catid) FROM ".DB_PREFIX."category",1);
    $root_depath =_getDepth(intval($rootid));
    $depth = ($root_depath+1);
	$array	= array(
		'catid'=>$catid,
	    'modalias'=>'outside',
		'catname'=>$catname,
		'treeid'=>0,
		'rootid'=>0,
		'depth'=>0,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>2,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->insert(DB_PREFIX."category",$array);
	if($result){
		Core_Command::runlog("","添加案例分类成功[$catename]",1);
		Core_Fun::halt("保存成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("保存失败","",1);
	}
}

function saveedit_nodeoutside(){
	global $db;
	$id					= Core_Fun::rec_post('id',1);
	$catname			= Core_Fun::rec_post('catname',1);
	$modalias			= Core_Fun::rec_post('modalias',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);
	$founderr			= false;
	
	if(!Core_Fun::isnumber($id)){
	    $founderr	= true;
		$errmsg	   .= "ID丢失.<br />";
	}
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}

	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$array	= array(
		'catname'=>$catname,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->update(DB_PREFIX."category",$array,"catid=$id");
	if($result){
		Core_Command::runlog("","编辑导航成功[id=$id]");
		Core_Fun::halt("编辑成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("编辑失败","",2);
	}
}











function saveadd_list(){
	global $db;
	$rootid			= Core_Fun::rec_post('rootid',1);
	$catname			= Core_Fun::rec_post('catname',1);
    $modalias			= Core_Fun::rec_post('modalias',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$dirname			= Core_Fun::rec_post('dirname',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);
	$founderr			= false;

	if(!Core_Fun::isnumber($rootid)){
	    $founderr	= true;
		$errmsg	   .="导航父类不能为空.<br />";
	}
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}

	if(!Core_Fun::ischar($dirname)){
	    $founderr	= true;
		$errmsg	   .="栏目标识不能为空.<br />";
	}
	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$catid	= $db->fetch_newid("SELECT MAX(catid) FROM ".DB_PREFIX."category",1);
	$modate = getCatModule(intval($rootid));
    $root_depath =_getDepth(intval($rootid));
    $depth = ($root_depath+1);
	$array	= array(
		'catid'=>$catid,
	    'modalias'=>$modate["modalias"],
		'catname'=>$catname,
		'treeid'=>getTreeID(intval($rootid)),
		'rootid'=>$rootid,
		'depth'=>$depth,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'dirname'=>$dirname,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->insert(DB_PREFIX."category",$array);
	if($result){
		Core_Command::runlog("","添加案例分类成功[$catename]",1);
		Core_Fun::halt("保存成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("保存失败","",1);
	}
}

function saveedit_list(){
	global $db;
    $id					= Core_Fun::rec_post('id',1);
	$catname			= Core_Fun::rec_post('catname',1);
	$rootid			    = Core_Fun::rec_post('rootid',1);
	$modalias			= Core_Fun::rec_post('modalias',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);
	$founderr			= false;

	if(!Core_Fun::isnumber($id)){
	    $founderr	= true;
		$errmsg	   .= "ID丢失.<br />";
	}
	if(!Core_Fun::isnumber($rootid)){
	    $founderr	= true;
		$errmsg	   .="导航父类不能为空.<br />";
	}
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}

	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$modate = getCatModule(intval($rootid));
	$array	= array(
	    'modalias'=>$modate["modalias"],
		'catname'=>$catname,
		'treeid'=>getTreeID(intval($rootid)),
		'rootid'=>$rootid,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->update(DB_PREFIX."category",$array,"catid=$id");
	if($result){
		Core_Command::runlog("","编辑导航成功[id=$id]");
		Core_Fun::halt("编辑成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("编辑失败","",2);
	}
}





function _getDepth($id) {
	   global $db;
        $sql = "SELECT depth FROM ".DB_PREFIX."category WHERE catid='".intval($id)."'";
        $data = $db->fetch_first($sql);
        if (!empty($data)) {
            return intval($data['depth']);
        }
        else {
            return 0;
        }
    }



function selectCategoryOneNode($nodeid, $value, $name, $text='请选择') {
		global $db;
        $temps = '';
        $temps .= "<select name='$name' id='$name'>";
        $temps .= "<option value=''>$text</option>";
        $temps .= getOneNodeOption(intval($nodeid), $value);        
        $temps .= "</select>";
        return $temps;
    }

function getOneNodeOption($nodeid, $invalue) {
		global $db;
        $temp = '';
        $node_sql = "SELECT catid,catname FROM ".DB_PREFIX."category".
                    " WHERE catid='".intval($nodeid)."'";
        $node_row =$db->fetch_first($node_sql);
        if (!empty($node_row)){
            $temp .= "<option value='".$node_row['catid']."'";
            if (intval($node_row['catid']) == intval($invalue)) {
                $temp .= " selected";
            }
            $temp .= ">".$node_row['catname']."</option>";
            
            $temp = $temp._getOptionChild($node_row['catid'], $invalue);
        }
        return $temp;
    }
    



function _getOptionChild($rootid, $inputvalue, $args='') {
		global $db;
        $args = $args;
        $child_sql = "SELECT catid,catname,depth FROM ".DB_PREFIX."category".
                        " WHERE rootid='$rootid' ORDER BY orders ASC";
        $child_data = $db->getall($child_sql);
        foreach ($child_data as $key=>$value) {
            $args .= "<option value='".$value['catid']."'";
            if (intval($value['catid']) == intval($inputvalue)) {
                $args .= " selected";
            }
            $depth_mark ='';
			if($value['depth']==1){
				$depth_mark = "&nbsp;&nbsp;├ ";
			}else{
				for($i=2; $i<=$value['depth']; $i++){
					$depth_mark .= "&nbsp;&nbsp;│";
				}
				$depth_mark .= "&nbsp;&nbsp;├ ";
			}     
            $args .= ">".$depth_mark.$value['catname']."</option>";
            $args = _getOptionChild($value['catid'], $inputvalue, $args);
        }
        return $args;
    }






 function edit_nodelist() {

	Core_Auth::checkauth("categoryedit");
	global $db,$tpl;
    $id = Core_Fun::rec_post('id');
	if(!Core_Fun::isnumber($id)){
		Core_Fun::halt("ID丢失","",2);
	}
	$sql	= "SELECT * FROM ".DB_PREFIX."category WHERE catid=$id";
	$category	= $db->fetch_first($sql);
	if(!$category){
		Core_Fun::halt("数据不存在","",2);
	}else{
		$data = getData($id);
		$category['modname'] =$data['modname'];
	//	$tpl->assign("flag_checkbox",Core_Mod::checkbox($cate['flag'],"flag","审核"));
	//	$tpl->assign("elite_checkbox",Core_Mod::checkbox($cate['elite'],"elite","推荐"));
		$tpl->assign("id",$id);
	//	$tpl->assign("comeurl",$GLOBALS['comeurl']);
	    $tpl->assign("category",$category);
	}

    }





 function edit_nodeabout() {

	Core_Auth::checkauth("categoryedit");
	global $db,$tpl;
    $id = Core_Fun::rec_post('id');
	if(!Core_Fun::isnumber($id)){
		Core_Fun::halt("ID丢失","",2);
	}
	$sql	= "SELECT * FROM ".DB_PREFIX."category WHERE catid=$id";
	$category	= $db->fetch_first($sql);
	if(!$category){
		Core_Fun::halt("数据不存在","",2);
	}else{
		$data = getData($id);
		$category['modname'] =$data['modname'];
	//	$tpl->assign("flag_checkbox",Core_Mod::checkbox($cate['flag'],"flag","审核"));
	//	$tpl->assign("elite_checkbox",Core_Mod::checkbox($cate['elite'],"elite","推荐"));
		$tpl->assign("id",$id);
	//	$tpl->assign("comeurl",$GLOBALS['comeurl']);
	    $tpl->assign("category",$category);
	}

    }






    

function saveedit_nodeabout(){
	Core_Auth::checkauth("saveedit_nodeabout");
	global $db;
	$id					= Core_Fun::rec_post('id',1);
	$catname			= Core_Fun::rec_post('catname',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);


	$founderr	= false;
	if(!Core_Fun::isnumber($id)){
	    $founderr	= true;
		$errmsg	   .= "ID丢失.<br />";
	}
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}
	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$array = array(
		'catname'=>$catname,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->update(DB_PREFIX."category",$array,"catid=$id");
	if($result){
		Core_Command::runlog("","编辑案例分类成功[id=$id]");
		Core_Fun::halt("编辑成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("编辑失败","",2);
	}
}



function saveedit_nodelist(){
	Core_Auth::checkauth("saveedit_nodelist");
	global $db;
	$id					= Core_Fun::rec_post('id',1);
	$catname			= Core_Fun::rec_post('catname',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);


	$founderr	= false;
	if(!Core_Fun::isnumber($id)){
	    $founderr	= true;
		$errmsg	   .= "ID丢失.<br />";
	}
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}
	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$array = array(
		'catname'=>$catname,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->update(DB_PREFIX."category",$array,"catid=$id");
	if($result){
		Core_Command::runlog("","编辑案例分类成功[id=$id]");
		Core_Fun::halt("编辑成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("编辑失败","",2);
	}
}



function getData($id) {
	    global $db;
        $sql = "SELECT v.*, m.modname,m.color AS modcolor FROM ".DB_PREFIX."category AS v".
                " LEFT JOIN ".DB_PREFIX."module AS m ON v.modalias=m.alias".
                " WHERE v.catid='".intval($id)."'";
		$data=$db->fetch_first($sql);
        return $data;
    }



 function getTreeID($id) {
	    global $db;
        $treeid = 0;
        $sql = "SELECT catid,rootid FROM ".DB_PREFIX."category WHERE catid='".intval($id)."'";
        $rows = $db->fetch_first($sql);
        if (!empty($rows)) {
            if (intval($rows['rootid']) == 0){
                $treeid = $rows['catid'];
            }
            else {
                $treeid = getTreeID($rows['rootid']);
            }
        }
        return $treeid;
    }

function getCatModule($id) {
	 	global $db;
        $sql = "SELECT v.modalias,m.modname FROM ".DB_PREFIX."category AS v".
                " LEFT JOIN ".DB_PREFIX."module AS m ON v.modalias=m.alias".
                " WHERE v.catid='".intval($id)."'";
        return $db->fetch_first($sql);
}

function getOrders($rootid=0) {
		 	global $db;
        return $db->fetch_newid("SELECT MAX(orders) FROM ".DB_PREFIX."category WHERE rootid='{$rootid}'", 1);
}


function setting(){
	Core_Auth::checkauth("categoryedit");
	global $db,$tpl,$page;
    $pagesize	= 30;
	$searchsql	= " WHERE 1=1";
	$countsql	= "SELECT COUNT(catid) FROM ".DB_PREFIX."category".$searchsql;
    $total		= $db->fetch_count($countsql);
    $pagecount	= ceil($total/$pagesize);
	$nextpage	= $page+1;
	$prepage	= $page-1;
	$start		= ($page-1)*$pagesize;
	//$sql		= "SELECT * FROM ".DB_PREFIX."category".
	//	          $searchsql." ORDER BY orders ASC LIMIT $start, $pagesize";
	$category		= $db->getall($sql);
	$url		= $_SERVER['PHP_SELF'];
	$showpage	= Core_Page::adminpage($total,$pagesize,$page,$url,10);
	$tpl->assign("total",$total);
	$tpl->assign("pagecount",$pagecount);
	$tpl->assign("page",$page);
	$tpl->assign("showpage",$showpage);
	$tpl->assign("category",$category);
}

function add(){
	Core_Auth::checkauth("categoryadd");
	global $tpl,$db;
	$orders  = $db->fetch_newid("SELECT MAX(orders) FROM ".DB_PREFIX."category",1);
	$tpl->assign("flag_checkbox",Core_Mod::checkbox("1","flag","审核"));
	$tpl->assign("elite_checkbox",Core_Mod::checkbox("1","elite","推荐"));
	$tpl->assign("orders",$orders);
}

function add_nodelist(){
	Core_Auth::checkauth("categoryadd_nodelist");
	global $tpl,$db;
	$selectlist=selectListModule('', 'modalias');
	$orders  = $db->fetch_newid("SELECT MAX(orders) FROM ".DB_PREFIX."category",1);
	$tpl->assign("flag_checkbox",Core_Mod::checkbox("1","flag","审核"));
	$tpl->assign("elite_checkbox",Core_Mod::checkbox("1","elite","推荐"));
	$tpl->assign("orders",$orders);
    $tpl->assign("module_select",$selectlist);
}

function add_nodeabout(){
//	Core_Auth::checkauth("categoryadd_nodelist");
	global $tpl,$db;
	$selectlist=selectListModule('', 'modalias');
	$orders  = $db->fetch_newid("SELECT MAX(orders) FROM ".DB_PREFIX."category",1);
	$tpl->assign("orders",$orders);
    $tpl->assign("module_select",$selectlist);
}






 function selectListModule($value, $name, $text='请选择') {
        $temps = '';
        $temps .= "<select name='$name' id='$name'>";
        $temps .= "<option value=''>$text</option>";
        $temps .= getListModuleOption(trim($value));
        $temps .= "</select>";
        return $temps;
}

 function getListModuleOption($invalue) {
	   global $db;
        $sql = "SELECT modid,modname,alias FROM ".DB_PREFIX."module WHERE (alias!='about' AND alias!='outside') AND enabled='1'  ORDER BY modid ASC";
        $data =$db->getall($sql);
        $temp = '';
        foreach($data as $key=>$value){
            $temp .= "<option value='".trim($value['alias'])."'";
            if (trim($invalue) == trim($value['alias'])) {
                $temp .= ' selected';
            }
            $temp .= ">".$value['modname']."</option>";
        } 
        return $temp;
}


function edit(){
	Core_Auth::checkauth("casecateedit");
	global $db,$tpl;
    $id = Core_Fun::rec_post('id');
	if(!Core_Fun::isnumber($id)){
		Core_Fun::halt("ID丢失","",2);
	}
	$sql	= "SELECT * FROM ".DB_PREFIX."category WHERE catid=$id";
	$cate	= $db->fetch_first($sql);
	if(!$cate){
		Core_Fun::halt("数据不存在","",2);
	}else{
		$cate['imgname'] = Core_Mod::getpicname($cate['logoimg']);
		$tpl->assign("flag_checkbox",Core_Mod::checkbox($cate['flag'],"flag","审核"));
		$tpl->assign("elite_checkbox",Core_Mod::checkbox($cate['elite'],"elite","推荐"));
		$tpl->assign("id",$id);
		$tpl->assign("comeurl",$GLOBALS['comeurl']);
	    $tpl->assign("cate",$cate);
	}
}

function saveadd(){
	Core_Auth::checkauth("casecateadd");
	global $db;
	$modalias			= Core_Fun::rec_post('modalias',1);
	$catname			= Core_Fun::rec_post('catname',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);
	$founderr			= false;
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}
	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$catid	= $db->fetch_newid("SELECT MAX(catid) FROM ".DB_PREFIX."category",1);
	$array	= array(
		'catid'=>$catid,
		'modalias'=>$modalias,
		'catname'=>$catname,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->insert(DB_PREFIX."category",$array);
	if($result){
		Core_Command::runlog("","添加案例分类成功[$catename]",1);
		Core_Fun::halt("保存成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("保存失败","",1);
	}
}



function saveadd_nodelist(){
	Core_Auth::checkauth("categorysaveadd_nodelist");
	global $db;

	$modalias			= Core_Fun::rec_post('modalias',1);
	$catname			= Core_Fun::rec_post('catname',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$dirname            = Core_Fun::rec_post('dirname',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);
	$founderr			= false;
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}
	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$catid	= $db->fetch_newid("SELECT MAX(catid) FROM ".DB_PREFIX."category",1);
	$array	= array(
		'catid'=>$catid,
	    'modalias'=>$modalias,
		'catname'=>$catname,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'dirname'=>	$dirname,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->insert(DB_PREFIX."category",$array);
	if($result){
		Core_Command::runlog("","添加案例分类成功[$catename]",1);
		Core_Fun::halt("保存成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("保存失败","",1);
	}
}


function saveadd_nodeabout(){
	Core_Auth::checkauth("categorysaveadd_nodeabout");
	global $db;
	$catname			= Core_Fun::rec_post('catname',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);
	$founderr			= false;
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}
	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$catid	= $db->fetch_newid("SELECT MAX(catid) FROM ".DB_PREFIX."category",1);
	$array	= array(
		'catid'=>$catid,
	    'modalias'=>'about',
		'catname'=>$catname,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'dirname'=>	$dirname,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->insert(DB_PREFIX."category",$array);
	if($result){
		Core_Command::runlog("","添加案例分类成功[$catename]",1);
		Core_Fun::halt("保存成功","ljcms_category.php",0);
	}else{
		Core_Fun::halt("保存失败","",1);
	}
}



function saveedit(){
	Core_Auth::checkauth("categoryedit");
	global $db;
	$id					= Core_Fun::rec_post('id',1);
	$catname			= Core_Fun::rec_post('catname',1);
    $asname			    = Core_Fun::rec_post('asname',1);
	$orders			    = Core_Fun::rec_post('orders',1);
	$flag			    = Core_Fun::rec_post('flag',1);
	$catpic			    = Core_Fun::rec_post('catpic',1);
	$metatitle			= Core_Fun::rec_post('metatitle',1);
	$metakeyword		= Core_Fun::rec_post('metakeyword',1);
	$metadescription	= Core_Fun::rec_post('metadescription',1);
	$purview			= Core_Fun::rec_post('purview',1);
	$ismenu			    = Core_Fun::rec_post('ismenu',1);
	$isaccessory		= Core_Fun::rec_post('isaccessory',1);
	$linktype		    = Core_Fun::rec_post('linktype',1);
	$outurl			    = $_POST['outurl'];
	$tplindex		    = Core_Fun::strip_post('tplindex',1);
	$tpllist		    = Core_Fun::detect_number(Core_Fun::rec_post('tpllist',1));
	$tpldetail		    = Core_Fun::detect_number(Core_Fun::rec_post('tpldetail',1));
	$pagemax			= Core_Fun::detect_number(Core_Fun::rec_post('pagemax',1));
	$orderby			= Core_Fun::rec_post('orderby',1);

/*
	$pathname			= Core_Fun::rec_post('pathname',1);
	$intro				= Core_Fun::strip_post('intro',1);
	$orders				= Core_Fun::detect_number(Core_Fun::rec_post('orders',1));
	$flag				= Core_Fun::detect_number(Core_Fun::rec_post('flag',1));
	$elite				= Core_Fun::detect_number(Core_Fun::rec_post('elite',1));
	$cssname			= Core_Fun::rec_post('cssname',1);
	$img				= Core_Fun::rec_post('img',1);
	$target				= Core_Fun::detect_number(Core_Fun::rec_post('target',1),1);
	$linktype			= Core_Fun::detect_number(Core_Fun::rec_post('linktype',1),1);
	$linkurl			= Core_Fun::strip_post('linkurl',1);

	'catname',
	'asname', 
	'orders', 
	'flag',
	'catpic',
	'metatitle',
	'metakeyword', 
	'metadescription',
    'purview', 
	'ismenu', 
	'isaccessory',
	'linktype', 
	'outurl',
    'tplindex',
	'tpllist', 
	'tpldetail',			
	'pagemax', 
	'orderby'
*/


	$founderr	= false;
	if(!Core_Fun::isnumber($id)){
	    $founderr	= true;
		$errmsg	   .= "ID丢失.<br />";
	}
	if(!Core_Fun::ischar($catname)){
	    $founderr	= true;
		$errmsg	   .="导航名称不能为空.<br />";
	}
	if($founderr == true){
	    Core_Fun::halt($errmsg,"",1);
	}
	$array = array(
		'catname'=>$catname,
		'asname'=>$sname,
	    'orders'=>$orders,
		'flag'=>$flag,
		'catpic'=>$catpic,
		'metatitle'=>$metatitle,
		'metakeyword'=>$metakeyword,
		'metadescription'=>$metadescription,
		'purview'=>$purview,
		'ismenu'=>$ismenu,
		'isaccessory'=>$isaccessory,
		'linktype'=>$linktype,
		'outurl'=>$outurl,
		'tplindex'=>$tplindex,
		'tpllist'=>$tpllist,
		'tpldetail'=>$tpldetail,
		'pagemax'=>$pagemax,
		'orderby'=>$orderby,
	);
	$result = $db->update(DB_PREFIX."category",$array,"catid=$id");
	if($result){
		Core_Command::runlog("","编辑案例分类成功[id=$id]");
		Core_Fun::halt("编辑成功","ljcms_category.php?".$GLOBALS['comeurl']."",0);
	}else{
		Core_Fun::halt("编辑失败","",2);
	}
}

function del(){
	//Core_Auth::checkauth("categorydel");
	$id  = isset($_REQUEST['id']) ? $_REQUEST['id'] : "";
	if($id=="" || is_null($id)){
		Core_Fun::halt("请选择要删除的数据","",1);
	}
	global $db;

		if(Core_Fun::isnumber($id)){
			$sql	= "SELECT catpic FROM ".DB_PREFIX."category WHERE catid=$id";
			$rows	= $db->fetch_first($sql);
			if($rows){
				if(Core_Fun::ischar($rows['catpic'])){
					Core_Fun::deletefile("../".$rows['catpic']);
				}
				$db->query("DELETE FROM ".DB_PREFIX."category WHERE catid=$id");
				//$db->query("DELETE FROM ".DB_PREFIX."case WHERE cateid=$id");
			}
		
	}



	Core_Command::runlog("","删除案例分类成功[id=$arrid]");
	Core_Fun::halt("删除成功","ljcms_category.php",0);
}

function updateajax($_id,$_action){
	Core_Auth::checkauth("casecateedit");
    if(Core_Fun::isnumber($_id)){
		global $db;
		switch($_action){
			case 'flagopen';
			$db->query("UPDATE ".DB_PREFIX."category SET flag=1 WHERE catid=$_id");
			break;
			case 'flagclose';
			$db->query("UPDATE ".DB_PREFIX."category SET flag=0 WHERE catid=$_id");
			break;
			case 'eliteopen';
			$db->query("UPDATE ".DB_PREFIX."category SET elite=1 WHERE catid=$_id");
			break;
			case 'eliteclose';
			$db->query("UPDATE ".DB_PREFIX."category SET elite=0 WHERE catid=$_id");
			break;
			default;
			break;
		}
	}
}

function savesetting(){
	Core_Auth::checkauth("casecateedit");
	$arrid  = isset($_REQUEST['id']) ? $_REQUEST['id'] : "";
	if($arrid=="" || is_null($arrid)){
		Core_Fun::halt("请选择要更新的数据","",1);
	}
	global $db;
	for($ii=0;$ii<count($arrid);$ii++){
        $id					= (int)($arrid[$ii]);
		$catname			= Core_Fun::rec_post("catname_".$id,1);
		$metatitle			= Core_Fun::rec_post("metatitle_".$id,1);
		$metakeyword		= Core_Fun::rec_post("metakeyword_".$id,1);
		$metadescription	= Core_Fun::rec_post("metadescription_".$id,1);
		$orders				= Core_Fun::detect_number(Core_Fun::rec_post("orders_".$id,1));
		if(Core_Fun::isnumber($id)){
			$array = array(
				'catname'=>$catname,
				'metatitle'=>$metatitle,
				'metakeyword'=>$metakeyword,
				'metadescription'=>$metadescription,
				'orders'=>$orders,
			);
			$db->update(DB_PREFIX."casecate",$array,"cateid=$id");
		}
	}
	Core_Fun::halt("批量更新成功","ljcms_category.php?action=setting",0);
}

$tpl->assign("action",$action);
$tpl->display(ADMIN_TEMPLATE."c.tpl");
$tpl->assign("runtime",runtime());
$tpl->assign("copyright",$libadmin->copyright());
?>